{extend name='public/content'}

{block name="title"}
	订单评价
{/block}

{block name="body"}
<div  ng-app="myApp" ng-controller="myCtrl"> 	
	
	<form class="layui-form">
		
		  <div class="layui-form-item">
		    <label class="layui-form-label">是否匿名</label>
		    <div class="layui-input-block">
		      <input type="checkbox" name="switch" lay-skin="switch" ng-model="switch" ng-init="switch=0">
		    </div>
		  </div>
		 <input type="" name="" ng-model="level_comment" ng-init="level_comment=5">
		 <div class="layui-form-item">  
			<div style="position:relative">
			    <div class="uploadimage"><input type="hidden" name="file_1"  ng-model="image" ng-init="image=''" ></div>
			    <a data-file="one" data-field="file_1" data-type="png,jpg" data-uptype="local" href="javascript:void(0)" class="uploadbutton">上传图片</a>
			</div>
		 </div>
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">文本域</label>
		    <div class="layui-input-block">
		      <textarea name="desc" placeholder="请输入内容" class="layui-textarea" ng-model="comment" ng-init="comment=''"></textarea>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="formDemo" ng-click="submitfopost()">立即提交</button>
		    
		    </div>
		  </div>
		</form>
	</div>

<div class=""></a>订单品论</div>

{/block}

{block name="script"}
 	<script type="text/javascript">
	require(['jquery','angular'], function () { 
		angular.module('myApp', [])
			.service('$factory',function($http){
				var locg={
		   			orderlist:function(id,call){
		   				var url ="{:url('order/goodbackapi')}?id="+id;
	                 	$http.get(url,{}).then(function(res){call(res)})	
		   			},
		   			postcommit:function(data,call){
		   				var url ="{:url('order/postcomm')}";
	                 	$http.post(url,data).then(function(res){call(res)})	
		   			}
		   		}
		   		return locg;
			})
			.controller('myCtrl', function($scope, $http,$factory) {
				$scope.order = {};
				$factory.orderlist("{$id}",function(res){
					$scope.order=res.data;
				})
				$scope.submitfopost=function(){
					 if($("input[name=switch]").is(':checked')){
					 	$scope.switch=1;
					 }
					 var pda={
					 	id:"{$id}",
					 	comment:$scope.comment,
					 	image:$scope.image,
					 	switch:$scope.switch,
					 	level_comment:$scope.level_comment
					 }
					 $factory.postcommit(pda,function(res){
						if(res.data==1){
							alert("评论成功");
						}
					 })
				}
				

				$('[name="file_1"]').on('change', function () {
			        $(this).parent().attr('data-tips-image', this.value).css('backgroundImage', 'url(' + this.value + ')');
					$scope.$apply(function() {   
			            	$scope.image = $('[name="file_1"]').val();   
			        });
			 	});
				
			})
			.filter('trustHtml', function ($sce) {
		        return function (input) {
		            return $sce.trustAsHtml(input);
		        }
		    });


	})
</script>
{/block}

{block name="style"}
 <style type="text/css">
 	
 </style>
{/block}